<?php
// check if async request
$bAjaxRequest = FALSE;
if ( isset ($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest"){
    $bAjaxRequest = TRUE;
}

$sErrorId = strtoupper(uniqid());
$strError = "EROARE php[ID:{$sErrorId}][IP:".((isset($_SERVER['REMOTE_ADDR']))?$_SERVER['REMOTE_ADDR']:'0.0.0.0')."] => Severity: {$severity} | Message: {$message} | Filename: {$filepath} | Line Number: {$line}";
log_message('error', $strError);
//$strError = "A aparut o eroare la procesarea cererii.<br />[ERRID:{$sErrorId}]";


if ($bAjaxRequest === FALSE){
// print html version of the error
print <<< EOD
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A Error was encountered</h4>

<p>$strError</p>

</div>
EOD;
  
}else if($bAjaxRequest === TRUE){
    // print json version of the error
    $aError = array(
        "error" => TRUE,
        "type" => "script",
        "description" => $strError
    );
    echo json_encode($aError);
}
die();
/* End of file error_php.php*/